import java.nio.ByteBuffer;
//import java.util.ArrayList;

public class MVAnalyzer {

	final int block_height = 16;
	final int block_width = 16;
	final int search_range = 2;

	int img_width;
	int img_height;
	//int [][] prev_image;
	
	ByteBuffer prev = null;
	
	MVAnalyzer(int width, int height) {
		img_width = width;
		img_height = height;
		//prev_image = new int[img_height][img_width];
		prev = ByteBuffer.allocateDirect(img_width * img_height * 3);
		prev.clear();
	}

	public native void sayHello();
	
	public native double getMovement(ByteBuffer prev, ByteBuffer cur, int w, int h, int r, int bw, int bh); 

    static { 
        System.loadLibrary("MVAnalyzer"); 
    }
    
	double getScore(ByteBuffer buffer) {
		//long x = System.nanoTime()/1000000;
		double score = getMovement(prev, buffer, img_width, img_height, search_range, block_width, block_height);
		//System.out.println("JT: " + ((System.nanoTime()/1000000) - x));
		prev.clear();
		buffer.position(0);
		prev.position(0);
		prev.put(buffer);
		return score;
	}

	class location {
		public int x, y;

		location(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

}
